package com.zjweu.hkg.DAO;

import com.zjweu.hkg.POJO.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommentDAO {
    @Select("select * from Comment where articleId=#{articleId}")
    List<Comment> getCommentsByArticleId(int articleId);
    @Insert("insert into Comment (fatherCommentId,articleId,userId,commentContent,createTime,updateTime) values (#{fatherCommentId},#{articleId},#{userId},#{commentContent},now(),now())")
    //自动返回更新的commentId
    @Options(useGeneratedKeys = true, keyProperty = "commentId")
    int addCommentByArticleId(Comment comment);
}
